package Dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import entity.Flower;

public class FlowerDao extends BaseDao{
	public Connection conn;

	public PreparedStatement pstmt;

	public ResultSet rs;

	public List<Flower> getList(){
		List<Flower> list=new ArrayList<Flower>();
		try {
            conn=super.getConnection();
            String sql="SELECT * from  flower ";
            pstmt=conn.prepareStatement(sql);
            rs=pstmt.executeQuery();
            while (rs.next()) {
			    Flower fio=new Flower();
			    fio.setId(rs.getInt("id"));
			    fio.setName(rs.getString("name"));
			    fio.setAnothername(rs.getString("anothername"));
			    fio.setProperty(rs.getString("property"));
			    fio.setPrice(rs.getFloat("price"));
			    fio.setProduction(rs.getString("production"));
			    list.add(fio);
            }
		} catch (Exception e) {
			// TODO: handle exception
		}finally {
			super.closeAll(conn, pstmt, rs);
		}
		return list;
	}
}
